import Vue from 'vue';
import store from '../../../../index';
export default {
    updateCartNumber(state){
        let userId = store.getters.currentUserFn && store.getters.currentUserFn.userId ? store.getters.currentUserFn.userId : 0
        let url = `${Vue.prototype.NW_API_API_LOCALE_VERSION}/shopping/cart/user/${userId}/item/number`;
        Vue.prototype.xurl.getSyncLoading(url).then((data) => {
            if (data.success) {
                let tempObj = {
                    cartGoodsLength:data.result,
                }
                state.cartObj = Object.assign({},state.cartObj,tempObj)
            } else if (data.errMsg) {
                Vue.$toast({message: data.errMsg});
            } else {
                Vue.$toast({message: '购物车信息获取失败，请重新获取'});
            }
        })
    },
}